package p366;/**
 * @Author：ming
 * @Date：2023/10/17 10:11 PM
 * @Filename：Lc2905
 */

/**
 * @author ming
 */
public class Lc2905 {
    public int[] findIndices(int[] nums, int indexDifference, int valueDifference) {
            int[] answer = {-1, -1};
            int len = nums.length;
            boolean flag = false;
            int max = nums[0];
            int min = nums[0];
            for (int i = 0; i < len; i++) {
                    if(nums[i]>max){
                            max = nums[i];
                    }
                    if(nums[i]<min){
                            min= nums[i];
                    }
            }
            if((max-min)<valueDifference){
                    return answer;
            }
            for (int i = 0; i < len; i++) {
                    if(flag){
                            break;
                    }
                    for (int j = i+indexDifference; j < len; j++) {
                            if(Math.abs(nums[i]-nums[j])>=valueDifference){
                                    answer[0]=i;
                                    answer[1]=j;
                                    flag = true;
                                    break;
                            }
                    }
            }
            return answer;
    }

}
